<?php

namespace App\Http\Controllers\Home;


use App\Http\Requests\Request;
use App\Models\Register;
use Session;
use Code;
class RegisterController extends BaseController
{
    /**
     * 初始化
     * RegisterController constructor.
     * @param Register $register
     */
    public function __construct(Register $register)
    {
          parent::__construct();
          $this->register=$register;
    }

    public function getRegister()
    {
        return view('home/recharge/register');
    }

    /**
     * 用户注册
     */
    public function postRegister()
    {
        $res = $this->register->register(request());
        if ($res['state'] == 0 || $res['state'] == 1 || $res['state'] == 2 || $res['state'] == 3 || $res['state'] == 400)
        {
            return redirect()->back()->with('message', $res['msg'])->withInput();
        }
        if ($res['state'] == 200) {
            return redirect('login')->with('message', $res['msg'])->withInput();
        }

    }




}
